package com.newtouch.cq.base.starter.business.model.vo;

import com.newtouch.cq.base.starter.business.entity.SysMenu;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@JsonInclude(Include.NON_NULL)
@ApiModel("菜单树模型")
public class MenuTreeModel implements Serializable, BaseParentAble<MenuTreeModel> {
	private static final long serialVersionUID = 6002921275643650309L;

	@ApiModelProperty("菜单标识")
	protected Long id;
	@ApiModelProperty("父级菜单标识")
	protected Long parentId;
	@ApiModelProperty("菜单标题")
	protected String title;
	@ApiModelProperty("请求链接（菜单的时候，前端URL）")
	protected String path;
	@ApiModelProperty("图标")
	protected String icon;
	@ApiModelProperty("自己菜单集合")
	protected List<MenuTreeModel> children;

	public MenuTreeModel(SysMenu menu) {
		super();
		this.id = menu.getId();
		this.parentId = menu.getParentId();
		this.title = menu.getMenuName();
		this.path = menu.getUrl();
		this.icon = menu.getIcon();
	}

	@Override
	public void addChildEle(MenuTreeModel child) {
		children.add(child);
	}

	@Override
	public void initialChildren() {
		children = new ArrayList<>();
	}

}
